package com.example;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author およそ神
 * @version JDK 1.8
 */
@EnableEurekaClient
@SpringBootApplication
@MapperScan(basePackages = "com.fan.mapper.**")
@EnableDiscoveryClient// @EnableEurekaClient 开启服务发现客户端的注解，可以用来获取一些配置的信息，得到具体的微服务
@EnableCircuitBreaker // 开启对熔断的支持
public class PersonProvider8001 {
    public static void main(String[] args) {
        SpringApplication.run(PersonProvider8001.class, args);
        System.out.println("  __                                     _                \n" +
                " / _|                                   | |               \n" +
                "| |_ __ _ _ __  _______  _ __   __ _ ___| |__   ___ _ __  \n" +
                "|  _/ _` | '_ \\|_  / _ \\| '_ \\ / _` / __| '_ \\ / _ \\ '_ \\ \n" +
                "| || (_| | | | |/ / (_) | | | | (_| \\__ \\ | | |  __/ | | |\n" +
                "|_| \\__,_|_| |_/___\\___/|_| |_|\\__, |___/_| |_|\\___|_| |_|\n" +
                "                                __/ |                     \n" +
                "                               |___/                      ");
    }
    // 增加一个servlet
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
        return servletRegistrationBean;
    }


}
